package com.test.web.controller;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.test.web.pojo.User;
import com.test.web.service.UserService;
import com.test.web.service.impl.UserServiceImpl;

/**
 * Servlet implementation class JNDICallServlet
 */
public class JNDICallServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		UserService userService = new UserServiceImpl();
		List<User> users = userService.allByJNDI();
		
		User user = null;
		int size = users.size();
		for(int i = 0 ; i < size ; i++) {
			user = users.get(i);
			System.out.println("user[" + i + "]:name->" + user.getName() + "|age->" + user.getAge() + "|address:" + user.getAddress() + "|");
		}
		response.getWriter().append("JNDI Called");
	}

}
